import { CookieModule } from 'ngx-cookie';
import { LockScreenService } from './service/lock-screen.service';
import { LoaderEmitter } from './pace-loading/loader-emitter.emitter';
import { TokenService } from './service/token.service';
import { WeiXinService } from './service/wei-xin.service';
import { BrowserService } from './service/browser.service';
import { DocumentTileService } from './service/document-tile.service';
import { LoadingService } from './service/loading.service';
import { LoadingComponent } from './loading/loading.component';
import { PaceLoadingComponent } from './pace-loading/pace-loading.component';

import { NgModule, Optional, SkipSelf } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CommonShareModule } from 'web-module-shared';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
    imports: [
        CommonModule,
        CommonShareModule,
        CookieModule.forRoot()
    ],
    declarations: [LoadingComponent, PaceLoadingComponent],
    providers: [
        LoadingService,
        DocumentTileService,
        BrowserService,
        WeiXinService,
        TokenService,
        LockScreenService,
        LoaderEmitter
    ],
    exports: [
        CookieModule,
        CommonModule,
        LoadingComponent,
        PaceLoadingComponent
    ]
})
export class CommonCoreModule {
    // static forRoot(config: UserServiceConfig): ModuleWithProviders {
    //   return {
    //     ngModule: CoreModule,
    //     providers: [
    //       { provide: UserServiceConfig, useValue: config }
    //     ]
    //   };
    // }

    constructor( @Optional() @SkipSelf() parentModule: CommonCoreModule) {
        if (parentModule) {
            throw new Error(
                'CoreModule is already loaded. Import it in the AppModule only');
        }
    }
}
